package com.jython.flink;

import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;

import java.util.ArrayList;

public class WordCount5 {
    public static void main(String[] args) {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        ArrayList<String> arr1 = new ArrayList<>();
        arr1.add("1");
        arr1.add("2");
        arr1.add("3");
        ArrayList<ArrayList<String>> arr = new ArrayList<>();
        arr.add(arr1);
        arr.add(arr1);
        arr.add(arr1);
        DataStream<ArrayList<ArrayList<String>>> arr2= env.fromElements(arr);
        DataStream<Object> tt= arr2.flatMap(new FlatMapFunction<ArrayList<ArrayList<String>>, Object>() {
            @Override
            public void flatMap(ArrayList<ArrayList<String>> arrayLists, Collector<Object> collector) throws Exception {
                for (ArrayList<String> s:arrayLists) {
                    collector.collect(s);
                }
            }
        });
        tt.map(x->{
            System.out.println(x);
            return x;
        });

        try {
            env.execute("ok");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
